#include "Query.h"
#include "QueryLoader.h"
#include "FullSearchEngine.h"
#include "AsteriskSearchEngine.h"

void usage()
{
    std::cout <<
		"Incorrect argument.\n"
		"To run use following syntax: 'search_engine input_filename'.\n"
		;
}

int main(int argc, char **argv)
{
	if (argc != 2)
	{
		usage();
		return 1;
	}
	
	Query *q;
	QueryLoader l;

	try{

	q = l.loadQueryFromFile(argv[1]);

	if (!q)
	{
		return 1;
	}
			
	SearchEngine *fse = new FullSearchEngine(q);
	fse->search();
	delete fse;

	SearchEngine *ase = new AsteriskSearchEngine(q);	
	ase->search();
	delete ase;
	
	q->clear();

	}catch(...){std::cout << "Unexpected error!\n";}

	clearOperators();

	return 0;
}
